module.exports = () => {
	// 返回中间件函数
	return async function permission(app, next) {
		let {$dx} = app;
		// 获取 当前请求的云函数 + 路径
		const path = $dx.request.functionName +'/'+ $dx.request.url;
		// 校验
		if (!$dx.auth || (!$dx.auth.role.includes('admin') && !$dx.auth.permission.includes(path))) {
			$dx.error('没有权限～', null, 4003);
		}
		await next() // 执行后续中间件
	}
}
